<?python
    from turbogears import identity
    from mnemoply import model

    departments = model.CashRegisterDepartment.selectBy(cashRegister=obj)
    dts = []
    for d in departments:
        dts.extend(model.CashRegisterDepartmentTrend.selectBy(department=d))
?>
<span xmlns:py="http://genshi.edgewall.org/">
    <table>
        <thead>
            <tr>
                <th>Department</th>
                <th>Trend</th>
                <th>Actions</th>
            </tr>
        </thead>

        <tbody>
            <tr py:for="dt in dts">
                <td><a href="/CashRegisterDepartment/${dt.department.id}">${dt.department.title}</a></td>
                <td><a href="/Trend/${dt.trend.id}">${dt.trend.title}</a></td>
                <td>
                    <span py:if="identity.has_any_permission('dba', 'CashRegisterDepartment/edit')">
                        <a href="delete_department_trend?dt_id=${dt.id}">delete</a>
                    </span>
                </td>
            </tr>
        </tbody>
    </table>

    <hr />

    <span py:if="identity.has_any_permission('dba', 'CashRegisterDepartmentTrend/edit')">
        ${ET(tab.add_form(records=dict(department_id=departments)))}
    </span>
</span>
